package com.small.nine.wxmp.domain.bean.wx.template;

import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.small.nine.wxmp.common.JsonService;
import com.small.nine.wxmp.utils.wx.JsonUtils;
import lombok.Data;

/**
 * 微信公众号设置所属行业
 *
 * @author sheng_zs@126.com
 * @date 2021-08-13 10:23
 */
@Data
public class WxTemplateSetIndustryBean implements JsonService {
    private static final long serialVersionUID = -1277224438711154747L;

    /**
     * 公众号模板消息所属行业编号：主行业
     */
    @JsonProperty("industry_id1")
    private String primaryIndustry;

    /**
     * 公众号模板消息所属行业编号
     */
    @JsonProperty("industry_id2")
    private String secondaryIndustry;

    /**
     * 初始化
     *
     * @param primaryIndustry   主行业
     * @param secondaryIndustry 副行业
     * @return {@link WxTemplateSetIndustryBean}
     */
    public static WxTemplateSetIndustryBean getInstance(String primaryIndustry, String secondaryIndustry) {
        if (StrUtil.hasBlank(primaryIndustry, secondaryIndustry)) {
            throw new IllegalArgumentException("参数有误");
        }
        WxTemplateSetIndustryBean bean = new WxTemplateSetIndustryBean();
        bean.setPrimaryIndustry(primaryIndustry);
        bean.setSecondaryIndustry(secondaryIndustry);
        return bean;
    }

    @Override
    public String toJson() {
        return JsonUtils.writeValueAsString(this);
    }
}
